/********************************************************/
/*	Copyright (C) 2012 Gong Li Bin			*/
/*	Project:	MapReduce			*/
/*	Author:		gong_libin			*/
/*	Date:		2013_05_06			*/
/*	File:		MrSquidTest.cpp			*/
/********************************************************/

#include "MrDb.h"
#include "MrDef.h"
#include "MrTcp.h"
#include "MrPro.h"
#include "MrUtl.h"
#include "MrTime.h"

int main(int argc, char* argv[])
{
	CMrDb CDb;
	CMrPro CPro;
	CMrTime CTime;
	MRPROKV_S* pstKv = NULL;
	char szSql[MR_BUFFER] = "SELECT * FROM MrCloud.MrDevice";

	CTime.MrTimeOn();

	if (NULL != (pstKv = MrProKvMalloc(MR_BUFFER, MR_PACKET))) {
		if (MR_SUCCESS == CDb.MrDbConnect((char*)"172.16.8.211", (char*)"13306")) {
			if (CDb.MrDbSend(MR_DEF_SELT, szSql) > 0) {
				if (MR_SUCCESS == CDb.MrDbRecv(pstKv)) {
					MR_PRINT("Result:\n");
					MrProKvDisplay(pstKv, MR_BUFFER);
				}
				else {
					MR_ERROR("Failed to MrDbRecv\n");
				}
			}
			else {
				MR_ERROR("Failed to MrDbSend\n");
			}
			CDb.MrDbClose();
		}
		else {
			MR_ERROR("Failed to MrDbConnect\n");
		}
	}
	else {
		MR_ERROR("Failed to MrDbMalloc\n");
	}

	CTime.MrTimeOff();
	CTime.MrTimeDisplay();

	return MR_SUCCESS;
}
